fix: raise MiMo TTS legacy timeout default#6939
fix: raise MiMo TTS legacy timeout default#69391zzxy1 wants to merge 3 commits intoAstrBotDevs:masterfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses an issue where MiMo TTS audio generation could time out, especially for longer outputs or older configurations. It increases the default timeout to 60 seconds and introduces a migration path to automatically update existing 20-second timeouts, ensuring smoother operation without requiring manual configuration changes for users. Comprehensive regression tests have been added to validate this behavior. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Hey - I've found 2 issues, and left some high level feedback:
- The legacy migration logic hardcodes
20as the old timeout; consider introducing aLEGACY_MIMO_TTS_TIMEOUT = 20constant so the comparison stays in sync with any future changes and makes the intent clearer. - The tests manually call
asyncio.run(provider.terminate())in multiple places; factoring this into a small helper or fixture would reduce duplication and make it easier to adjust the termination behavior later.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The legacy migration logic hardcodes `20` as the old timeout; consider introducing a `LEGACY_MIMO_TTS_TIMEOUT = 20` constant so the comparison stays in sync with any future changes and makes the intent clearer.
- The tests manually call `asyncio.run(provider.terminate())` in multiple places; factoring this into a small helper or fixture would reduce duplication and make it easier to adjust the termination behavior later.
## Individual Comments
### Comment 1
<location path="astrbot/core/provider/sources/mimo_tts_api_source.py" line_range="41" />
<code_context>
+ provider_config.get("timeout", DEFAULT_MIMO_TTS_TIMEOUT)
+ )
+ # MiMo TTS often needs longer than the legacy 20s default for large outputs.
+ if timeout in (None, 20):
+ timeout = DEFAULT_MIMO_TTS_TIMEOUT
+ self.timeout = timeout
</code_context>
<issue_to_address>
**suggestion:** Using `20` as a magic number here makes the migration behavior harder to follow.
This condition bakes in `20` as a special legacy value tied to the old default. To improve maintainability, consider naming this value (e.g., `LEGACY_MIMO_TTS_TIMEOUT`) or deriving the check from the raw config/legacy default instead, so behavior stays clear if defaults change later.
Suggested implementation:
```python
timeout = normalize_timeout(
provider_config.get("timeout", DEFAULT_MIMO_TTS_TIMEOUT)
)
# MiMo TTS often needs longer than the legacy default for large outputs.
# Treat `LEGACY_MIMO_TTS_TIMEOUT` as a special value so behavior stays clear if defaults change.
if timeout in (None, LEGACY_MIMO_TTS_TIMEOUT):
timeout = DEFAULT_MIMO_TTS_TIMEOUT
self.timeout = timeout
```
To fully implement the change and avoid the magic number, you should also:
1. Define a `LEGACY_MIMO_TTS_TIMEOUT` constant near the other MiMo-related defaults in `mimo_tts_api_source.py`, e.g. close to where `DEFAULT_MIMO_TTS_TIMEOUT` is declared:
```python
LEGACY_MIMO_TTS_TIMEOUT = 20 # seconds; previous MiMo TTS timeout default
DEFAULT_MIMO_TTS_TIMEOUT = ...
```
(Preserve the existing value and placement of `DEFAULT_MIMO_TTS_TIMEOUT`; only insert the new constant above or nearby.)
2. If this module is imported elsewhere via `*` or re-exported, no further changes are needed, since the constant is only used internally here.
</issue_to_address>
### Comment 2
<location path="tests/test_mimo_api_sources.py" line_range="139-144" />
<code_context>
}
+def test_mimo_tts_raises_legacy_default_timeout_to_60_seconds():
+ provider = _make_tts_provider({"timeout": "20"})
+ try:
+ assert provider.timeout == 60
+ finally:
+ asyncio.run(provider.terminate())
+
+
</code_context>
<issue_to_address>
**suggestion (testing):** Add coverage for legacy timeout expressed as an integer and missing/None timeout values
This only exercises the legacy timeout when given as a string. Since `provider_config.get("timeout", ...)` may return an `int` or `str` and the migration logic checks `timeout in (None, 20)` after `normalize_timeout`, please also add tests for `{"timeout": 20}`, `{"timeout": None}`, and (if not already covered) the case where `timeout` is omitted. That will validate the migration behavior across all legacy configurations.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Code Review
This pull request updates the default timeout for MiMo TTS operations from 20 seconds to 60 seconds. This change is implemented by introducing a new DEFAULT_MIMO_TTS_TIMEOUT constant, updating the default configuration, and modifying the MiMoTTSAPISource class to ensure that both unspecified timeouts and the legacy 20-second timeout are upgraded to 60 seconds. New unit tests have been added to confirm this behavior, ensuring that the legacy default is correctly raised while explicit custom timeouts are preserved. There are no review comments to provide feedback on.
| provider_config.get("timeout", DEFAULT_MIMO_TTS_TIMEOUT) | ||
| ) | ||
| # MiMo TTS often needs longer than the legacy 20s default for large outputs. | ||
| if timeout in (None, 20): |
# Conflicts: # tests/test_mimo_api_sources.py
Summary
Closes #6841
Testing
Summary by Sourcery
Increase MiMo TTS default timeout and ensure legacy configurations transparently adopt the new default while preserving explicit custom timeouts.
Bug Fixes:
Enhancements:
Tests: